ecef0252c0f9fba2fae189e138c663096e2b4275,opennms-provision/opennms-provision-api/src/main/java/org/opennms/netmgt/provision/support/BasicDetector.java,BasicDetector,isServiceDetected,#InetAddress#DetectorMonitor#,64
Before Change
// Connection refused!! Continue to retry.
System.out.println("put before");
cE.printStackTrace();
detectorMonitor.info(this, cE, "Attempting to connect to address: %s attempt #%s",address.getHostAddress(),attempts);
} catch (NoRouteToHostException e) {
// No Route to host!!!
e.printStackTrace();
detectorMonitor.info(this, e, "%s: No route to address %s was available", getServiceName(), address.getHostAddress());
throw new UndeclaredThrowableException(e);
} catch (InterruptedIOException e) {
// Expected exception
e.printStackTrace();
detectorMonitor.info(this, e, "%s: Did not connect to to address within timeout: %d attempt: %d", getServiceName(), timeout, attempts);
} catch (IOException e) {
e.printStackTrace();
detectorMonitor.info(this, e, "%s: An unexpected I/O exception occured contacting address %s",getServiceName(), address.getHostAddress());
} catch (Throwable t) {
t.printStackTrace();
detectorMonitor.failure(this, "%s: Failed to detect %s on address %s", getServiceName(), getServiceName(), address.getHostAddress());
detectorMonitor.error(this, t, "%s: An undeclared throwable exception was caught contating address %s", getServiceName(), address.getHostAddress());
} finally {
client.close();
}
After Change
abstract protected void onInit();
public boolean isServiceDetected(InetAddress address, DetectorMonitor detectorMonitor) {
String ipAddr = address.getHostAddress();
int port = getPort();
int retries = getRetries();
int timeout = getTimeout();
System.out.printf("Address: %s || port: %s || \n", address, getPort());
detectorMonitor.start(this, "Checking address: %s for %s capability", address, getServiceName());
Client<Request, Response> client = getClient();
for (int attempts = 0; attempts <= retries; attempts++) {
try {
client.connect(address, port, timeout);
detectorMonitor.attempt(this, attempts, "Attempting to connect to address: %s port %d attempt #%s",ipAddr,port,attempts);
if (attemptConversation(client)) {
return true;
}
} catch (ConnectException cE) {
// Connection refused!! Continue to retry.
System.out.println("put before");
cE.printStackTrace();
detectorMonitor.info(this, cE, "%s: Excpetion attempting to connect to address: %s port %d, attempt #%s",getServiceName(), ipAddr,port, attempts);
} catch (NoRouteToHostException e) {
// No Route to host!!!
e.printStackTrace();
detectorMonitor.info(this, e, "%s: No route to address %s was available", getServiceName(), ipAddr);
throw new UndeclaredThrowableException(e);
} catch (InterruptedIOException e) {
// Expected exception
e.printStackTrace();
detectorMonitor.info(this, e, "%s: Did not connect to to address %s port %d within timeout: %d attempt: %d", getServiceName(), ipAddr, port, timeout, attempts);
} catch (IOException e) {
e.printStackTrace();
detectorMonitor.info(this, e, "%s: An unexpected I/O exception occured contacting address %s port %d",getServiceName(), ipAddr, port);
} catch (Throwable t) {
t.printStackTrace();
detectorMonitor.failure(this, "%s: Failed to detect %s on address %s port %d", getServiceName(), getServiceName(), ipAddr, port);
detectorMonitor.error(this, t, "%s: An undeclared throwable exception was caught contating address %s port %d", getServiceName(), ipAddr, port);
} finally {
client.close();
}